#   /**
#   * Copyright (c) 2022 Beijing Jiaotong University
#   * PhotLab is licensed under [Open Source License].
#   * You can use this software according to the terms and conditions of the [Open Source License].
#   * You may obtain a copy of [Open Source License] at: [https://open.source.license/]
#   *
#   * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
#   * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
#   * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
#   *
#   * See the [Open Source License] for more details.
#   */
#   /**
#   * Author: Zheng Wang
#   * Created: Sep. 25, 2022
#   * Supported by: National Key Research and Development Program of China
#   */

import os
import logging
from .configuration import parse_configuration
from .core import phot_lab_engine
from .engine_shell import GraphEntity
from .engine_shell import functional
from .globals import TaskPriority
from .globals import TaskStatus
from .core import PhotLabEngine

logging_config_dict = parse_configuration.load_logging_config()

handlers = []
if "file" == logging_config_dict["output_direction"]:
    file_handler = logging.FileHandler(filename=logging_config_dict["filepath"], mode="a", encoding="utf-8")
    handlers.append(file_handler)
elif "stream" == logging_config_dict["output_direction"]:
    stream_handler = logging.StreamHandler(stream=logging_config_dict["stream"])
    handlers.append(stream_handler)
elif "both" == logging_config_dict["output_direction"]:
    file_handler = logging.FileHandler(filename=logging_config_dict["filepath"], mode="a", encoding="utf-8")
    stream_handler = logging.StreamHandler(stream=logging_config_dict["stream"])
    handlers.append(file_handler)
    handlers.append(stream_handler)
else:
    raise TypeError("output_direction must choice one of values in ['file','stream','both'],not {}"
                    .format(logging_config_dict["output_direction"]))

logging.basicConfig(level=logging_config_dict["log_level"],
                    format=logging_config_dict["log_format"],
                    handlers=handlers)
logging.debug("logging-root:{},id:{}".format(logging.root, id(logging.root)))
logging.debug("Global log configuration has successfully configured.")




